<?php

namespace app\index\controller;

use think\Cache;
use think\Controller;
use think\Db;
use think\Loader;
use think\Request;
use think\Validate;

class Shop extends Controller
{
    /**
     * 规格-属性 联动数据
     * */
    public function getSpecData()
    {
        $list = Db::name('mini_spec')->field('id,pid,name')->where(['pid' => 0])->order('id asc')->select();
        if ($list) {
            foreach ($list as &$v) {
                $child = Db::name('mini_spec')->field('id,pid,name')->where(['pid' => $v['id']])->order('id asc')->select();
                $v['attr'] = $child;
            }
            apiReturn(1, '获取数据成功', $list);
        } else {
            apiReturn(2, '暂无数据');
        }
    }
}
